package com.yien.springstudy.service.impl;

import com.yien.springstudy.domain.Product;
import com.yien.springstudy.exception.MyBizException;
import com.yien.springstudy.service.ProductService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Miaoxiong Fan
 * @since version
 */
@Service
public class ProductServiceImpl implements ProductService {

    @Override
    public void calcTotalPrice() {
        System.out.println("product服务总价计算调用");
        throw new MyBizException("product计算总结出错");
    }

    @Override
    public List<Product> list() {
        List<Product> result = new ArrayList<>();
        Product product = null;
        for (int i = 0; i < 10; i++) {
            product = new Product();
            product.setId("id" + i);
            product.setName("name" + i);
            product.setNumber("20190509" + i);
            result.add(product);
        }
        return result;
    }
}
